package com.atguigu.spzx.user.controller;

import com.atguigu.spzx.model.entity.user.Region;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.user.service.UserRegionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "地区信息模块")
@RestController
@RequestMapping("/api/user/region")
public class UserRegionController {
    @Resource
    UserRegionService userRegionService;
    @Operation(summary = "根据父id查询下一级地区信息")
    @GetMapping("/findByParentCode/{parentId}")
    public Result findByParentCode(@PathVariable("parentId")Long parentId){
        List<Region> regionList = userRegionService.findByParentCode(parentId);
        return Result.ok(regionList);
    }
}
